
<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title>字典列表</title>
    <link href="../../nuoyi/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../../nuoyi/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- bootstrap-table 表格插件样式 -->
    <link href="../../nuoyi/ajax/libs/bootstrap-table/bootstrap-table.min.css?v=20201129" rel="stylesheet"/>
    <link href="../../nuoyi/css/animate.css" rel="stylesheet"/>
    <link href="../../nuoyi/css/style.css?v=20200903" rel="stylesheet"/>
    <link href="../../nuoyi/ruoyi/css/ry-ui.css?v=4.6.0" rel="stylesheet"/>

</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="addModel()">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary" onclick="updateModel()">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<a id="scroll-up" href="#" class="btn btn-sm display"><i class="fa fa-angle-double-up"></i></a>
<script src="../../nuoyi/js/jquery.min.js"></script>
<script src="../../nuoyi/js/bootstrap.min.js"></script>
<!-- bootstrap-table 表格插件 -->
<script src="../../nuoyi/ajax/libs/bootstrap-table/bootstrap-table.min.js?v=20201129"></script>
<script src="../../nuoyi/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js?v=20201129"></script>
<script src="../../nuoyi/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js?v=20201129"></script>
<!-- jquery-validate 表单验证插件 -->
<script src="../../nuoyi/ajax/libs/validate/jquery.validate.min.js"></script>
<script src="../../nuoyi/ajax/libs/validate/messages_zh.min.js"></script>
<script src="../../nuoyi/ajax/libs/validate/jquery.validate.extend.js"></script>
<!-- jquery-validate 表单树插件 -->
<script src="../../nuoyi/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
<!-- 遮罩层 -->
<script src="../../nuoyi/ajax/libs/blockUI/jquery.blockUI.js"></script>
<script src="../../nuoyi/ajax/libs/iCheck/icheck.min.js"></script>
<script src="../../nuoyi/ajax/libs/layer/layer.min.js"></script>
<script src="../../nuoyi/ajax/libs/layui/layui.js"></script>
<script src="../../nuoyi/ruoyi/js/common.js?v=4.6.0"></script>
<script src="../../nuoyi/ruoyi/js/ry-ui.js?v=4.6.0"></script>
<script class="add-content" type="text/html">
   <div style="padding: 10px" >
       <div class="form-group">
           <label class="col-sm-1 control-label is-required">key名称：</label>
           <div class="col-sm-1">
               <input class="form-control " id="key-name" type="text"  name="key-name" required>
           </div>
       </div>
       <div class="form-group">
           <label class="col-sm-1 control-label is-required">value值：</label>
           <div class="col-sm-1">
               <input class="form-control " id="value-name" type="text" name="value-name" required>
           </div>
       </div>
   </div>
</script>
<div style="display: none" id="update-content">
    <div style="padding: 10px" >
       <div id="update-content2"></div>
    </div>
</div>
<script>


    var url = decodeURI(window.location.href);
    var argsIndex = url .split("?obj=");
    var arg = argsIndex[1];
    $(function() {
        var options = {
            url: "/dicti/valueList/"+arg,
            modalName: "字典列表",
            columns: [{
                checkbox: true
            },
                {
                    title: '序号',
                    align: 'center',
                    halign: 'center',
                    width: 40,
                    formatter: function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize=$('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber=$('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    field: 'key',
                    title: 'key'
                },
                {
                    field: 'value',
                    title: 'value'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var obj = row.id
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick=select(this) objdata='+obj+'><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    function updateModel() {
        var obj= $("#bootstrap-table").bootstrapTable('getSelections');
        if(obj==''||obj==undefined){
           return  layer.msg("请先选择一行数据");
        }
        if(obj.length>1){
            return  layer.msg("只能选择一行数据");
        }
        var obj2=new Object();
        for (let i = 0; i < obj.length; i++) {
            obj2=obj[i];
        }
        var str=' <div class="form-group">\n' +
            '            <label class="col-sm-1 control-label is-required">key名称：</label>\n' +
            '            <div class="col-sm-1">\n' +
            '                <input  id="key-name11" type="text" value='+obj2.key+'  name="key-name1" required>\n' +
            '            </div>\n' +
            '        </div>\n' +
            '        <div class="form-group">\n' +
            '            <label class="col-sm-1 control-label is-required">value值：</label>\n' +
            '            <div class="col-sm-1">\n' +
            '                <input  id="value-name1" type="text" value='+obj2.value+' name="value-name1" required>\n' +
            '            </div>\n' +
            '        </div>'

        $('#update-content2').html(str)
        layer.open({
            content: $('#update-content').html()
            ,area: ['400px', '260px'] //自定义文本域宽高
            ,title:'类型新增'
            ,btn: ['确定', '取消']
            ,yes: function(){
                var data=$('#key-name11').val()
                alert(data)
            }
            ,btn2: function(){
                //按钮【取消】的回调
                return 0;
            }
        });

    }

    function addModel(){
      var index= layer.open({
            type: 1,
            content: $(".add-content").html()
            ,area: ['400px', '260px'] //自定义文本域宽高
            ,title:'字典键值新增'
            ,btn: ['确定', '取消']
            ,yes: function(){
                var keyname=$('input[name="key-name"]').val();
                var valuename=$('input[name="value-name"]').val()
                if(!keyname||!valuename){
                   return layer.msg("请输入key和value的值")
                }
               var obj=new Object();
                obj.id=arg;
                obj.key=keyname;
                obj.value=valuename;
                var result=urldataget('post','/dicti/addvaluebyid',obj)
                if(result.code==0){
                    layer.msg("添加成功")
                    $("#bootstrap-table").bootstrapTable('refresh');
                    layer.close(index)
                }
            }
            ,btn2: function(){
                //按钮【取消】的回调
                return 0;
            }
        });
    }

    function select(row) {
        var obj=$(row).attr("objdata")

        var result=data.rows;
        var servername=result.serverName
        var argnote=result.argnote
        var resultObj=result.resultObj
        $("#title-main").html("服务名称： "+servername)
        $("#arg-main").html("参数列表: "+argnote)
        $("#content-main").html("返回结果：\n"+resultObj)

        layer.open({
            content: $('#log-info').html()
            ,area: ['500px', '500px'] //自定义文本域宽高
            ,title:'类型新增'
            ,btn: ['确定', '取消']
            ,yes: function(){
            }
            ,btn2: function(){
                //按钮【取消】的回调
                return 0;
            }
        });
    }

    function urldataget(requestObject,url,data) {
        var data1='';
        $.ajax({
            type: requestObject,
            url: url,
            data:data,
            async:false,
            success: function(data) {
                data1=data;
            }
        })
        return data1
    }



</script>
</body>
</html>